using System;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using System.Windows.Forms;
using ComponentFactory.Krypton.Toolkit;
using DukeyCssFetch.api;

namespace DukeyCssFetch.UI
{
	// Token: 0x02000031 RID: 49
	public class BrowserFrm : Form
	{
		// Token: 0x060001EB RID: 491 RVA: 0x00016E1C File Offset: 0x0001501C
		public BrowserFrm()
		{
			
			this.InitializeComponent();
			try
			{
				this.webBrowser1.Url = new Uri(Comm.CurrentUrl);
			}
			catch
			{
			}
			this.cbbianma.SelectedIndex = 0;
		}

		// Token: 0x060001ED RID: 493 RVA: 0x00016EE0 File Offset: 0x000150E0
		private void btnGetHtml_Click(object sender, EventArgs e)
		{
			try
			{
				if (this.webBrowser1.Url == null)
				{
					MessageBox.Show("请先加载网页!");
				}
				else
				{
					using (StreamReader streamReader = new StreamReader(this.webBrowser1.DocumentStream, this.method_2(this.webBrowser1.Url.ToString())))
					{
						Comm.ContainerHtml = streamReader.ReadToEnd();
					}
					base.DialogResult = DialogResult.OK;
				}
			}
			catch
			{
				MessageBox.Show("还没有输入网址");
			}
		}

		// Token: 0x060001EE RID: 494 RVA: 0x00016F80 File Offset: 0x00015180
		private void btnGO_Click(object sender, EventArgs e)
		{
			string text = this.txtUrl.Text.Trim();
			if (!text.ToLower().Contains("http://") && !text.ToLower().Contains("https://"))
			{
				this.webBrowser1.Url = new Uri("http://" + text);
				return;
			}
			this.webBrowser1.Url = new Uri(text);
		}

		// Token: 0x060001EF RID: 495 RVA: 0x00016FF0 File Offset: 0x000151F0
		protected override void Dispose(bool disposing)
		{
			if (disposing && this.icontainer_0 != null)
			{
				this.icontainer_0.Dispose();
			}
			base.Dispose(disposing);
		}

		// Token: 0x060001F0 RID: 496 RVA: 0x00017010 File Offset: 0x00015210
		private void InitializeComponent()
		{
			this.splitContainer1 = new SplitContainer();
			this.btnGetHtml = new KryptonButton();
			this.btnGO = new KryptonButton();
			this.txtUrl = new KryptonTextBox();
			this.webBrowser1 = new WebBrowser();
			this.cbbianma = new ComboBox();
			this.splitContainer1.Panel1.SuspendLayout();
			this.splitContainer1.Panel2.SuspendLayout();
			this.splitContainer1.SuspendLayout();
			base.SuspendLayout();
			this.splitContainer1.Dock = DockStyle.Fill;
			this.splitContainer1.Location = new Point(0, 0);
			this.splitContainer1.Name = "splitContainer1";
			this.splitContainer1.Orientation = Orientation.Horizontal;
			this.splitContainer1.Panel1.Controls.Add(this.cbbianma);
			this.splitContainer1.Panel1.Controls.Add(this.btnGetHtml);
			this.splitContainer1.Panel1.Controls.Add(this.btnGO);
			this.splitContainer1.Panel1.Controls.Add(this.txtUrl);
			this.splitContainer1.Panel2.Controls.Add(this.webBrowser1);
			this.splitContainer1.Size = new Size(708, 395);
			this.splitContainer1.SplitterDistance = 68;
			this.splitContainer1.TabIndex = 0;
			this.btnGetHtml.Location = new Point(646, 20);
			this.btnGetHtml.Name = "btnGetHtml";
			this.btnGetHtml.Size = new Size(50, 25);
			this.btnGetHtml.TabIndex = 3;
			this.btnGetHtml.Values.Text = "提取";
			this.btnGetHtml.Click += new EventHandler(this.btnGetHtml_Click);
			this.btnGO.Location = new Point(468, 21);
			this.btnGO.Name = "btnGO";
			this.btnGO.Size = new Size(50, 25);
			this.btnGO.TabIndex = 3;
			this.btnGO.Values.Text = "转到";
			this.btnGO.Click += new EventHandler(this.btnGO_Click);
			this.txtUrl.Location = new Point(24, 24);
			this.txtUrl.Name = "txtUrl";
			this.txtUrl.Size = new Size(438, 20);
			this.txtUrl.TabIndex = 2;
			this.webBrowser1.Dock = DockStyle.Fill;
			this.webBrowser1.Location = new Point(0, 0);
			this.webBrowser1.MinimumSize = new Size(20, 20);
			this.webBrowser1.Name = "webBrowser1";
			this.webBrowser1.Size = new Size(708, 323);
			this.webBrowser1.TabIndex = 0;
			this.cbbianma.DropDownStyle = ComboBoxStyle.DropDownList;
			this.cbbianma.FormattingEnabled = true;
			this.cbbianma.Items.AddRange(new object[]
			{
				"网页编码(自动检测)",
				"utf-8",
				"gb2312",
				"GBK",
				"Big5"
			});
			this.cbbianma.Location = new Point(529, 24);
			this.cbbianma.Name = "cbbianma";
			this.cbbianma.Size = new Size(111, 20);
			this.cbbianma.TabIndex = 42;
			base.AutoScaleDimensions = new SizeF(6f, 12f);
			base.AutoScaleMode = AutoScaleMode.Font;
			base.ClientSize = new Size(708, 395);
			base.Controls.Add(this.splitContainer1);
			base.Name = "BrowserFrm";
			base.ShowIcon = false;
			base.StartPosition = FormStartPosition.CenterScreen;
			this.Text = "浏览器窗口";
			this.splitContainer1.Panel1.ResumeLayout(false);
			this.splitContainer1.Panel1.PerformLayout();
			this.splitContainer1.Panel2.ResumeLayout(false);
			this.splitContainer1.ResumeLayout(false);
			base.ResumeLayout(false);
		}

		// Token: 0x060001E9 RID: 489 RVA: 0x00016E08 File Offset: 0x00015008
		[CompilerGenerated]
		private int method_0()
		{
			return this.int_0;
		}

		// Token: 0x060001EA RID: 490 RVA: 0x00016E10 File Offset: 0x00015010
		[CompilerGenerated]
		private void method_1(int value)
		{
			this.int_0 = value;
		}

		// Token: 0x060001EC RID: 492 RVA: 0x00016E70 File Offset: 0x00015070
		private Encoding method_2(string string_0)
		{
			Encoding result = Encoding.UTF8;
			switch (this.method_0())
			{
			case 0:
				result = Comm.GetPageEncoding(string_0);
				return result;
			case 2:
				result = Encoding.GetEncoding("gb2312");
				return result;
			case 3:
				result = Encoding.GetEncoding("gbk");
				return result;
			case 4:
				result = Encoding.GetEncoding("big5");
				return result;
			}
			result = Encoding.UTF8;
			return result;
		}

		// Token: 0x040001FB RID: 507
		private KryptonButton btnGetHtml;

		// Token: 0x040001FA RID: 506
		private KryptonButton btnGO;

		// Token: 0x040001FD RID: 509
		private ComboBox cbbianma;

		// Token: 0x040001F7 RID: 503
		private IContainer icontainer_0;

		// Token: 0x040001FE RID: 510
		[CompilerGenerated]
		private int int_0;

		// Token: 0x040001F8 RID: 504
		private SplitContainer splitContainer1;

		// Token: 0x040001F9 RID: 505
		private KryptonTextBox txtUrl;

		// Token: 0x040001FC RID: 508
		private WebBrowser webBrowser1;
	}
}
